/*
APPENDIX FIGURE 4
Moderation of Association between Firm-Level Exposure to PSL Mandates and Workers' reports of Access to PSL in States and Counties without PSL mandates by Firm Franchising
*/

cd "$exhibits_path"

use "$data_path/main_analysis_file.dta", clear

set scheme plotplain

* define controls
	global demog i.gender i.race2_harm c.age_text_clean i.kids i.eslhome i.enrolled i.cohabstatus
	global work i.manager i.longwork_yrs i.union c.hourwage_clean c.usualhours_clean 
	global statechars c.unionmem_pc c.unemp_rate  c.minwage_state  	c.race_black c.race_amind c.race_asian c.race_pacisl c.race_other c.race_multi c.hispan c.age_u5 c.age_5to9 c.age_10to14 c.age_75to84 c.age_85plus c.female_pc c.educ_pc_hsgrad c.educ_pc_somecoll c.educ_pc_assoc c.educ_pc_bach c.educ_pc_grad

label def Franchise_lab 1 "Franchise" 0 "Non-Franchise"
label val franchise_company Franchise_lab

* left panel
mi est: reg benefits_paidsick c.pct_emps_psl_place##i.franchise_company $demog $work  i.statelist i.year##i.month if  psl_law_places_hybd == 0, vce(cluster statelist) 

mimrgns, at(pct_emps_psl_place=(5(5)50)) over(franchise_company) cmdmargins vsquish esampvaryok
	marginsplot, ///
	title("{bf:All Industries}", size(small)) ///
	xtitle("% of Firm's Workers Exposed to PSL Mandate", size(small)) ///
	legend(row(1) pos(6)) ///
	plot1opt(lcolor(gs8) mcolor(gs8)) plot2opt(lcolor(green) mcolor(green)) ///
	 ci1opt(color(gs8)) ci2opt(color(green)) ///
	ytitle("% of Workers in Non-PSL Mandate States or Counties" "Reporting Access to Paid Sick", size(small)) ///
	ylabel(0 "0%" .1 "10%" .2 "20%" .3 "30%" .4 "40%" .5 "50%" .6 "60%",labsize(small)) ///
	xlabel(5 "5%" 10 "10%" 15 "15%" 20 "20%" 25 "25%" 30 "30%" 35 "35%" 40 "40%" 45 "45%" 50 "50%",labsize(small)) ///
		name(apx_fig4_left)


* right panel: regressing % of workers reporting access to paid sick on percent of workers in firm covered interacted with franchise status - includes only fast food firms
mi est: reg benefits_paidsick c.pct_emps_psl_place##i.franchise_company $demog $work i.statelist i.year##i.month if  psl_law_places_hybd == 0 & shift_ind == 8, vce(cluster statelist)

mimrgns, at(pct_emps_psl_place=(5(5)50)) over(franchise_company) cmdmargins vsquish esampvaryok
	marginsplot, ///
	title("{bf:Only Food Industry}", size(small)) ///
	xtitle("% of Firm's Workers Exposed to PSL Mandate", size(small)) ///
	legend(row(1) pos(6)) ///
	plot1opt(lcolor(gs8) mcolor(gs8)) plot2opt(lcolor(green) mcolor(green)) ///
	 ci1opt(color(gs8)) ci2opt(color(green)) ///
	ytitle("% of Workers in Non-PSL Mandate States or Counties" "Reporting Access to Paid Sick", size(small)) ///
	ylabel(0 "0%" .1 "10%" .2 "20%" .3 "30%" .4 "40%" .5 "50%" .6 "60%",labsize(small)) ///
	xlabel(5 "5%" 10 "10%" 15 "15%" 20 "20%" 25 "25%" 30 "30%" 35 "35%" 40 "40%" 45 "45%" 50 "50%",labsize(small)) ///
		name(apx_fig4_right)


* combining panels into final exhibit
graph combine apx_fig4_left apx_fig4_right
graph export "$exhibits_path/Appendix Figure 4.pdf", replace
